home *** CD-ROM | disk | FTP | other *** search
/ Champak 142 / Volume 142 Oct 17 2011 - Damaged.iso / Games / operation-graduates.swf / scripts / frame_41 / DoAction_13.as < prev    next >
Text File  |  2011-10-17  |  12KB  |  445 lines

  1. function spawnBoss()
  2. {
  3.    for(leftovers in enemyContainer)
  4.    {
  5.       explode(enemyContainer[leftovers]);
  6.    }
  7.    music.level.stop();
  8.    music.boss.start(0,999);
  9.    attachMovie("boss.core","boss",bossDepth);
  10.    boss._x = Stage.width / 2;
  11.    boss.red.gotoAndStop(1);
  12.    boss.orangeL.gotoAndStop(1);
  13.    boss.orangeR.gotoAndStop(1);
  14.    boss.yellowL.gotoAndStop(1);
  15.    boss.yellowR.gotoAndStop(1);
  16.    boss.center.gotoAndStop(1);
  17.    boss.center.shoot = centerShoot;
  18.    boss._y = int((- boss._height) / 2);
  19.    boss.onEnterFrame = bossExecute;
  20.    boss.move = bossMover;
  21.    boss.state = 0;
  22.    boss.emerger = 0;
  23.    boss.energy = 300;
  24.    boss.hit = false;
  25.    boss.arm1 = boss.red;
  26.    boss.arm1.shoot = redShoot;
  27.    boss.arm2 = boss.yellowL;
  28.    boss.arm3 = boss.yellowR;
  29.    boss.arm2.shoot = boss.arm3.shoot = yellowShoot;
  30.    boss.arm4 = boss.orangeL;
  31.    boss.arm5 = boss.orangeR;
  32.    boss.arm4.shoot = boss.arm5.shoot = orangeShoot;
  33.    i = 1;
  34.    while(i <= 5)
  35.    {
  36.       eval("boss.arm" + i).hit = false;
  37.       eval("boss.arm" + i).energy = 75;
  38.       eval("boss.arm" + i).explode = bossArmExplode;
  39.       eval("boss.arm" + i).firing = false;
  40.       eval("boss.arm" + i).alive = false;
  41.       eval("boss.arm" + i).hitCheck = armHitCheck;
  42.       i++;
  43.    }
  44.    boss.t = 0;
  45.    boss.s = boss._y;
  46.    boss.c = 144;
  47.    boss.d = 30;
  48. }
  49. function bossExecute()
  50. {
  51.    this.move();
  52.    var i = 1;
  53.    while(i <= 5)
  54.    {
  55.       var arm = eval("boss.arm" + i);
  56.       if(arm.hit)
  57.       {
  58.          arm.resetColor();
  59.          arm.hit = false;
  60.       }
  61.       i++;
  62.    }
  63.    if(this.state < 10)
  64.    {
  65.       if(this.arm1.alive)
  66.       {
  67.          this.arm1.hitCheck();
  68.       }
  69.       if(this.arm2.alive)
  70.       {
  71.          this.arm2.hitCheck();
  72.       }
  73.       if(this.arm3.alive)
  74.       {
  75.          this.arm3.hitCheck();
  76.       }
  77.       if(this.arm4.alive)
  78.       {
  79.          this.arm4.hitCheck();
  80.       }
  81.       if(this.arm5.alive)
  82.       {
  83.          this.arm5.hitCheck();
  84.       }
  85.    }
  86.    else
  87.    {
  88.       if(this.hit)
  89.       {
  90.          this.resetColor();
  91.          this.hit = false;
  92.       }
  93.       for(tpb in pBullets)
  94.       {
  95.          var cap = pBullets[tpb];
  96.          if(this.hitTest(cap._x,cap._y,false))
  97.          {
  98.             this.hit = true;
  99.             this.setRGB(16777215);
  100.             this.energy -= 5;
  101.             cap.removeMovieClip();
  102.             if(this.energy <= 0)
  103.             {
  104.                bossExplode();
  105.             }
  106.             return undefined;
  107.          }
  108.       }
  109.    }
  110. }
  111. function armHitCheck()
  112. {
  113.    for(tpb in pBullets)
  114.    {
  115.       var cap = pBullets[tpb];
  116.       if(this.ha.hitTest(cap._x,cap._y,false))
  117.       {
  118.          this.hit = true;
  119.          this.setRGB(16777215);
  120.          this.energy -= 5;
  121.          if(this.energy <= 0)
  122.          {
  123.             this.explode(cap._x,cap._y);
  124.             this.gotoAndStop(1);
  125.             this.alive = false;
  126.             var allArmsGone = true;
  127.             var i = 1;
  128.             while(i <= 5)
  129.             {
  130.                if(eval("boss.arm" + i)._currentframe != 1)
  131.                {
  132.                   allArmsGone = false;
  133.                }
  134.                i++;
  135.             }
  136.             if(allArmsGone)
  137.             {
  138.                boss.t = 0;
  139.                boss.state = 10;
  140.                boss.center.gotoAndPlay("emerge");
  141.             }
  142.          }
  143.          cap.removeMovieClip();
  144.          return undefined;
  145.       }
  146.    }
  147. }
  148. function bossArmExplode(xSpot, ySpot)
  149. {
  150.    var _loc1_ = this;
  151.    var xInc = (boss._x + _loc1_._x - xSpot) / 3;
  152.    var yInc = (boss._y + _loc1_._y - ySpot) / 3;
  153.    var _loc3_ = 0;
  154.    while(_loc3_ < 3)
  155.    {
  156.       var _loc2_ = explosionContainer.attachMovie("explosion2","explosion" + explosionCount++,explosionCount);
  157.       _loc2_._x = xSpot;
  158.       _loc2_._y = ySpot;
  159.       xSpot += xInc;
  160.       ySpot += yInc;
  161.       _loc2_.gotoAndStop(1);
  162.       _loc2_._visible = false;
  163.       _loc2_.delay = _loc3_ * 3;
  164.       _loc2_.onEnterFrame = function()
  165.       {
  166.          var _loc1_ = this;
  167.          if(!_loc1_._visible && _loc1_.delay <= 0)
  168.          {
  169.             _loc1_._visible = true;
  170.             _loc1_.gotoAndPlay(1);
  171.             playSound("sound.missile.explode");
  172.          }
  173.          else
  174.          {
  175.             _loc1_.delay = _loc1_.delay - 1;
  176.          }
  177.          if(_loc1_._currentframe == _loc1_._totalframes)
  178.          {
  179.             _loc1_.removeMovieClip();
  180.          }
  181.       };
  182.       _loc3_ = _loc3_ + 1;
  183.    }
  184. }
  185. function bossMover()
  186. {
  187.    switch(this.state)
  188.    {
  189.       case 0:
  190.          if(this.t < this.d)
  191.          {
  192.             this.t = this.t + 1;
  193.             this._y = Math.easeOutQuad(this.t,this.s,this.c,this.d);
  194.             if(this.t == this.d)
  195.             {
  196.                this.t = -1;
  197.                this.state = this.state + 1;
  198.             }
  199.          }
  200.          break;
  201.       case 1:
  202.          this.t = this.t + 1;
  203.          switch(this.t)
  204.          {
  205.             case 1:
  206.                this.yellowR.gotoAndPlay("emerge");
  207.                break;
  208.             case 6:
  209.                this.yellowL.gotoAndPlay("emerge");
  210.                break;
  211.             case 11:
  212.                this.orangeL.gotoAndPlay("emerge");
  213.                break;
  214.             case 15:
  215.                this.red.gotoAndPlay("emerge");
  216.                break;
  217.             case 21:
  218.                this.orangeR.gotoAndPlay("emerge");
  219.                break;
  220.             case 26:
  221.                this.t = 0;
  222.                this.state = this.state + 1;
  223.                var i = 1;
  224.                while(i <= 5)
  225.                {
  226.                   eval("this.arm" + i).alive = true;
  227.                   eval("this.arm" + i).energy = 50;
  228.                   i++;
  229.                }
  230.          }
  231.          break;
  232.       case 2:
  233.          this.t = this.t + 1;
  234.          if(this.t > 60)
  235.          {
  236.             this.t = 0;
  237.             this.state = this.state + 1;
  238.          }
  239.          break;
  240.       case 3:
  241.          this.t += 0.5;
  242.          if(this.t % 1 == 0 && eval("this.arm" + (this.t % 5 + 1)).alive)
  243.          {
  244.             eval("this.arm" + (this.t % 5 + 1)).gotoAndPlay("fire");
  245.          }
  246.          if(this.t > 45 || Math.abs(this._x - theHull._x) > 250)
  247.          {
  248.             this.t = 0;
  249.             this.s = this._x;
  250.             this.c = theHull._x - this._x;
  251.             this.d = Math.floor(Math.abs(this._x - theHull._x) / 3);
  252.             this.state = 5;
  253.          }
  254.          break;
  255.       case 4:
  256.          if(this.t % 10 == 0 && this.orangeR.alive)
  257.          {
  258.             this.orangeR.gotoAndPlay("fire");
  259.          }
  260.          else if(this.t % 10 == 5 && this.orangeL.alive)
  261.          {
  262.             this.orangeL.gotoAndPlay("fire");
  263.          }
  264.          this.t = this.t + 1;
  265.          if(this.t > 30)
  266.          {
  267.             this.state = this.state + 1;
  268.             this.t = 0;
  269.             this.s = this._x;
  270.             this.c = theHull._x - this._x;
  271.             this.d = Math.floor(Math.abs(this._x - theHull._x) / 3);
  272.          }
  273.          break;
  274.       case 5:
  275.          if(this.t < this.d)
  276.          {
  277.             this.t = this.t + 1;
  278.             this._x = Math.easeOutElastic(this.t,this.s,this.c,this.d);
  279.          }
  280.          if(this.t == this.d)
  281.          {
  282.             this.state = 2;
  283.          }
  284.          break;
  285.       case 10:
  286.          this.t = this.t + 1;
  287.          if(this.t % 33 == 0)
  288.          {
  289.             this.center.gotoAndPlay("fire");
  290.          }
  291.          if(this.t > 100)
  292.          {
  293.             this.resetColor();
  294.             this.state = 1;
  295.             this.t = 0;
  296.             this.center.gotoAndPlay("retract");
  297.          }
  298.    }
  299. }
  300. function bossExplode()
  301. {
  302.    var _loc1_ = this;
  303.    playSound("sound.boss.explode");
  304.    var _loc2_ = explosionContainer.attachMovie("explosion4","explosion" + explosionCount++,explosionCount);
  305.    _loc2_._x = boss._x;
  306.    _loc2_._y = boss._y;
  307.    _loc2_.onEnterFrame = function()
  308.    {
  309.       var _loc1_ = this;
  310.       if(_loc1_._currentframe == _loc1_._totalframes)
  311.       {
  312.          attachMovie("codeModulator","codeModulator",4999);
  313.          codeModulator._x = _loc1_._x;
  314.          codeModulator._y = _loc1_._y;
  315.          codeModulator.sinThing = 0;
  316.          codeModulator.onEnterFrame = function()
  317.          {
  318.             var _loc1_ = this;
  319.             _loc1_.sinThing += 0.1;
  320.             _loc1_._y += Math.sin(_loc1_.sinThing);
  321.             if(theHull.hitTest(_loc1_))
  322.             {
  323.                music.boss.stop();
  324.                playSound("sound.powerup");
  325.                music.intro.start(0,999);
  326.                endLevel();
  327.                _loc1_.removeMovieClip();
  328.             }
  329.          };
  330.          _loc1_.removeMovieClip();
  331.       }
  332.    };
  333.    boss.removeMovieClip();
  334. }
  335. function centerShoot()
  336. {
  337.    var _loc2_ = this;
  338.    var _loc1_ = eBullets.attachMovie("eBul1","bullet" + eBulletsCount++,eBulletsCount);
  339.    _loc1_._x = boss._x;
  340.    _loc1_._y = boss._y + 31;
  341.    _loc1_.vel = new Vector(theHull._x - _loc1_._x,theHull._y - _loc1_._y);
  342.    _loc1_.vel.setLength(8);
  343.    _loc1_.onEnterFrame = function()
  344.    {
  345.       var _loc1_ = this;
  346.       _loc1_._x += _loc1_.vel.x;
  347.       _loc1_._y += _loc1_.vel.y;
  348.       if(_loc1_._y > 400)
  349.       {
  350.          _loc1_.removeMovieClip();
  351.       }
  352.    };
  353. }
  354. function bossProjectileMove()
  355. {
  356.    var _loc1_ = this;
  357.    if(_loc1_.isHit)
  358.    {
  359.       _loc1_.resetColor();
  360.       _loc1_.isHit = false;
  361.    }
  362.    if(_loc1_.energy <= 0)
  363.    {
  364.       playSound("sound.missile.explode",(_loc1_._x - 300) / 6);
  365.       explode(_loc1_);
  366.    }
  367.    else
  368.    {
  369.       _loc1_._y += 8;
  370.       if(_loc1_._y > 400)
  371.       {
  372.          _loc1_.removeMovieClip();
  373.       }
  374.    }
  375. }
  376. function redShoot()
  377. {
  378.    var _loc1_ = misCon.attachMovie("missile3","missile" + misCount++,misCount);
  379.    var _loc2_ = new Object();
  380.    _loc2_.x = this._x + 62;
  381.    _loc2_.y = this._y + 81;
  382.    boss.localToGlobal(_loc2_);
  383.    _loc1_._x = _loc2_.x;
  384.    _loc1_._y = _loc2_.y;
  385.    _loc1_.move = bossProjectileMove;
  386.    _loc1_.isHit = false;
  387.    _loc1_.Q1logic = missileQ1;
  388.    _loc1_.Q2logic = missileQ2;
  389.    _loc1_.Q3logic = missileQ3;
  390.    _loc1_.Q4logic = missileQ4;
  391.    _loc1_.energy = 5;
  392. }
  393. function yellowShoot(leftSide)
  394. {
  395.    var _loc3_ = this;
  396.    var _loc1_ = misCon.attachMovie("missile4","missile" + misCount++,misCount);
  397.    var _loc2_ = new Object();
  398.    if(leftSide)
  399.    {
  400.       _loc2_.x = _loc3_._x - 61 + 14;
  401.       _loc2_.y = _loc3_._y + 80 + 27;
  402.    }
  403.    else
  404.    {
  405.       _loc2_.x = _loc3_._x + 29 + 14;
  406.       _loc2_.y = _loc3_._y + 43 + 27;
  407.    }
  408.    boss.localToGlobal(_loc2_);
  409.    _loc1_._x = _loc2_.x;
  410.    _loc1_._y = _loc2_.y;
  411.    _loc1_.move = bossProjectileMove;
  412.    _loc1_.isHit = false;
  413.    _loc1_.Q1logic = missileQ1;
  414.    _loc1_.Q2logic = missileQ2;
  415.    _loc1_.Q3logic = missileQ3;
  416.    _loc1_.Q4logic = missileQ4;
  417.    _loc1_.energy = 5;
  418. }
  419. function orangeShoot(leftSide)
  420. {
  421.    var _loc3_ = this;
  422.    var _loc1_ = misCon.attachMovie("boss.warhead","missile" + misCount++,misCount);
  423.    var _loc2_ = new Object();
  424.    if(leftSide)
  425.    {
  426.       _loc2_.x = _loc3_._x - 32 + 8;
  427.       _loc2_.y = _loc3_._y + 85 + 8;
  428.    }
  429.    else
  430.    {
  431.       _loc2_.x = _loc3_._x + 15 + 11;
  432.       _loc2_.y = _loc3_._y + 93 + 11;
  433.    }
  434.    boss.localToGlobal(_loc2_);
  435.    _loc1_._x = _loc2_.x;
  436.    _loc1_._y = _loc2_.y;
  437.    _loc1_.move = bossProjectileMove;
  438.    _loc1_.isHit = false;
  439.    _loc1_.Q1logic = missileQ1;
  440.    _loc1_.Q2logic = missileQ2;
  441.    _loc1_.Q3logic = missileQ3;
  442.    _loc1_.Q4logic = missileQ4;
  443.    _loc1_.energy = 5;
  444. }
  445.